Skip to content

Conversation

@jatin-bhateja
Copy link
Member

@jatin-bhateja jatin-bhateja commented Oct 27, 2025

Add new HalffloatVector type and corresponding concrete vector classes in addition to existing primitive vector types, maintaining operation parity with the FloatVector type.

  • Add necessary inline expander support.
    • Enable intrinsification for a few vector operations, namely ADD/SUB/MUL/DIV/MAX/MIN/FMA.
  • Use existing Float16 vector IR and backend support.
  • Extended the existing VectorAPI JTREG test suite for the newly added HalffloatVector operations.

The idea here is to first be at par with Float16 auto-vectorization support before intrinsifying new operations (conversions, reduction, etc).

The following are the performance numbers for some of the selected HalfflotVector benchmarking kernels compared to equivalent Float16OperationsBenchmark kernels.

{A2BA2D85-085A-489F-8DDD-0FCFB5986EA5}

Initial RFP[1] was floated on the panama-dev mailing list.

Kindly review the draft PR and share your feedback.

Best Regards,
Jatin

[1] https://mail.openjdk.org/pipermail/panama-dev/2025-August/021100.html


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8370691: Add new Float16Vector type and enable intrinsification of vector operations supported by auto-vectorizer (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28002/head:pull/28002
$ git checkout pull/28002

Update a local copy of the PR:
$ git checkout pull/28002
$ git pull https://git.openjdk.org/jdk.git pull/28002/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28002

View PR using the GUI difftool:
$ git pr show -t 28002

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28002.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 27, 2025

👋 Welcome back jbhateja! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 27, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Oct 27, 2025

@jatin-bhateja The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@jatin-bhateja
Copy link
Member Author

/label add hotspot-compiler-dev

@openjdk
Copy link

openjdk bot commented Oct 27, 2025

@jatin-bhateja
The hotspot-compiler label was successfully added.

@jatin-bhateja jatin-bhateja marked this pull request as ready for review November 8, 2025 02:18
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 8, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 8, 2025

Webrevs

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some quick comments.

We should be consistent in the naming, and rename Halfloat* to Float16*.

When you generate the fallback code for unary/binary etc can you push the carrier type and conversations into the uOp/bOp implementations so you don't have to explicitly operate on the carrier type and do the conversions as you do now e.g.,:

v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(-(shortBitsToFloat16(($type$)a).floatValue()))));

The transition of intrinsic arguments from vsp.elementType() to vsp.carrierType(), vsp.operType() is a little unfortunate. Is this because HotSpot cannot directly refer to the Float16 class from the incubating module? Requiring two arguments means they can get out of sync. Previously the class provided all the information needed, now arguably the type does.

@jddarcy
Copy link
Member

jddarcy commented Nov 11, 2025

Some quick comments.

We should be consistent in the naming, and rename Halfloat* to Float16*.

I concur, especially since there are multiple 16-bit floating-point formats in use including the IEEE 754 float16 as well as bfloat16.

@eme64
Copy link
Contributor

eme64 commented Nov 11, 2025

We already have a lot of things in the codebase now from previous issues that use HF everywhere, for example some node names, and the type. Should we maybe rename all of them to F16, or something else? Open question, not sure of the answer yet.

@PaulSandoz
Copy link
Member

We already have a lot of things in the codebase now from previous issues that use HF everywhere, for example some node names, and the type. Should we maybe rename all of them to F16, or something else? Open question, not sure of the answer yet.

I was only referring to the Java code, esp. the new public classes so they align with the Float16 element type. I do think it worthwhile to align so we are consistent across the platform. Revisiting the names in HotSpot, and their internal connection in Java, could be done in a separate PR?

@eme64
Copy link
Contributor

eme64 commented Nov 11, 2025

Revisiting the names in HotSpot, and their internal connection in Java, could be done in a separate PR?

Yes, exactly. Maybe even in a quick renaming PR before this issue. Would be quickly reviewed, and would allow us to see complete consistency going forward with this PR here.

@jatin-bhateja
Copy link
Member Author

jatin-bhateja commented Nov 12, 2025

Hi @PaulSandoz , Thanks for your comments. Please find below my responses.

When you generate the fallback code for unary/binary etc can you push the carrier type and conversations into the uOp/bOp implementations so you don't have to explicitly operate on the carrier type and do the conversions as you do now e.g.,:

v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(-(shortBitsToFloat16(($type$)a).floatValue()))));

Currently, uOp and uOpTemplates are part of the scaffolding logic and are sacrosanct; they are shared by various abstracted vector classes, and their semantics are defined by the lambda expression. I agree that explicit conversion in lambdas looks verbose, but moving them to uOpTemplate may fracture the lambda expression such that part of its semantics, i.e,. conversions, will seep into uOpTemplate, while what will appear at the surface will be the expression operating over primitive float values; this may become very confusing.

The transition of intrinsic arguments from vsp.elementType() to vsp.carrierType(), vsp.operType() is a little unfortunate. Is this because HotSpot cannot directly refer to the Float16 class from the incubating module?

Yes, the idea here was to clearly differentiate b/w elemType and carrierType and avoid passing Float16.class as an argument to intrinsic entry points. Unlike the VectorSupport class, Float16 is part of the incubating module and cannot be directly exposed to VM, i.e., we cannot create a vmSymbol for it during initialization. This would have made all the lane type checks within inline expand name-based rather than efficient symbol lookup.

Requiring two arguments means they can get out of sync. Previously the class provided all the information needed, now
arguably the type does.

Yes, from the compiler standpoint point all we care about is the carrier type, which determines the vector lane size. This is augmented with operation kind (PRIM / FP16) to differentiate a short vector lane from a float16 vector lane. Apart from this, we need to pass the VectorBox type to wrap the vector IR.

@jatin-bhateja
Copy link
Member Author

Some quick comments.
We should be consistent in the naming, and rename Halfloat* to Float16*.

I concur, especially since there are multiple 16-bit floating-point formats in use including the IEEE 754 float16 as well as bfloat16.

There are nomenclature issues that I am facing. Currently, all the Float16 concrete classes use the Halffloat prefix i.e., Halffloat64Vector, Halffloat128Vector; converting these to Float16 looks a little confusing, i.e., Float1664Vector, Float16128Vector, etc Kindly suggest a better name to represent these classes.

@jatin-bhateja jatin-bhateja changed the title 8370691: Add new HalffloatVector type and enable intrinsification of float16 vector operations 8370691: Add new Float16Vector type and enable intrinsification of vector operations supported by auto-vectorizer Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants